import { game } from 'cc'
import BTAction from '../../Base/BTAction'
import { NodeStatus } from '../../Enum/NodeStatus'
import BoardMgr from '../../Managers/BoardMgr'

export default class ActionAttack extends BTAction {
  private duration: number = 2000
  private startTime: number = 0

  constructor(duration: number = 2000) {
    super()
    this.duration = duration
  }
  
  onStart() {
    super.onStart()
    this.startTime = game.totalTime
    BoardMgr.Instance.hp -= 20
  }

  onUpdate() {
    if (game.totalTime - this.startTime > this.duration) {
      return NodeStatus.Success
    }
    return NodeStatus.Running
  }

  onEnd() {
    super.onEnd()
  }
}
